using UnityEngine;

public class visibleObjPhoton : MonoBehaviour
{
	public PhotonTransformView lerpScript;

	public bool isVisible;

	public bool isVisibleFast;

	private Renderer cashRenderer;

	private void Start()
	{
		if (!settings.offlineMode && lerpScript == null)
		{
			lerpScript = base.transform.GetComponentInParent<PhotonTransformView>();
		}
		if (cashRenderer == null)
		{
			cashRenderer = GetComponent<Renderer>();
		}
	}

	private void OnBecameVisible()
	{
		isVisibleFast = true;
		if (!settings.offlineMode)
		{
			if (lerpScript == null)
			{
				lerpScript = base.transform.GetComponentInParent<PhotonTransformView>();
			}
			if (lerpScript != null)
			{
				isVisible = true;
				CancelInvoke("delayInvisile");
			}
		}
		else
		{
			isVisible = true;
		}
	}

	public void SetVisibleWithDelay()
	{
		Invoke("OnBecameVisible", 0.1f);
	}

	private void OnBecameInvisible()
	{
		isVisibleFast = false;
		if (!settings.offlineMode)
		{
			if (lerpScript != null)
			{
				Invoke("delayInvisile", 0.3f);
			}
		}
		else
		{
			isVisible = false;
		}
	}

	private void delayInvisile()
	{
		if (lerpScript == null)
		{
			lerpScript = base.transform.GetComponentInParent<PhotonTransformView>();
		}
		isVisible = false;
	}
}
